/*
编写 : Hexh
时间 : 2012-11-7 10:31:36
*/
using System;
using System.Collections.Generic;
using FSBS.Core.Entity;
using FSBS.Core.Entity.IRespositories;
using HMIS.FrameWork;
using HMIS.FrameWork.DomainBase;

namespace FSBS.Facade.Impl
{
	/// <summary>
	///	 the impl of IFsbsQmCrifFacade
	/// </summary>
	public class FsbsQmCrifFacadeImpl : IFsbsQmCrifFacade
	{

		private readonly IFsbsQmCrifRepository FsbsQmCrifRepository;
		private readonly IFsbsQmStrlRepository FsbsQmStrlRepository;

		public FsbsQmCrifFacadeImpl(IFsbsQmCrifRepository FsbsQmCrifRepository, IFsbsQmStrlRepository FsbsQmStrlRepository)
		{
			this.FsbsQmCrifRepository = FsbsQmCrifRepository;
			this.FsbsQmStrlRepository = FsbsQmStrlRepository;
		}

		#region IFsbsQmCrif Entity Save,Get,Update,Delete

		public FsbsQmCrif Get(string id)
		{
			return FsbsQmCrifRepository.Get(id);
		}

		public FsbsQmCrif Load(string id)
		{
			return FsbsQmCrifRepository.Load(id);
		}

		public void SaveOrUpdate(FsbsQmCrif entity)
		{
			this.FsbsQmCrifRepository.SaveOrUpdate(entity);
		}

		public void Delete(string id)
		{
			FsbsQmCrifRepository.Delete(id);
		}
		
		public void PhysicsDelete(string id)
		{
			FsbsQmCrifRepository.PhysicsDelete(id);
		}

		public bool IsFieldExist(string fieldName, string fieldValue, string id)
		{
			return FsbsQmCrifRepository.IsFieldExist(fieldName, fieldValue, id);
		}
		
		public bool IsFieldExistWhere(string fieldName, string fieldValue, string id, string where)
		{
			return FsbsQmCrifRepository.IsFieldExistWhere(fieldName, fieldValue, id, where);
		}

		public void AddStrlInfo(string carid, string strcid)
		{
			FsbsQmStrl strlEntity = new FsbsQmStrl{
				StrcId = strcid,
				CarId = carid
			};
			FsbsQmStrlRepository.SaveOrUpdate(strlEntity);
		}
		
		#endregion
		
		#region Query 

		public IList<FsbsQmCrif> GetAll()
		{
			return FsbsQmCrifRepository.GetAll();
		}

		public IList<FsbsQmCrif> GetPlist(string query, string carState, int start, int limit, string sort, string dir, List<DataFilter> filters, out long total)
		{
			return FsbsQmCrifRepository.GetPlist(query, carState, start, limit, sort, dir, filters, out total);
		}

		public IList<FsbsQmCrif> GetPlistByStoreId(string storeid, string query, int start, int limit, string sort, string dir, List<DataFilter> filters, out long total)
		{
			return FsbsQmCrifRepository.GetPlistByStoreId(storeid, query, start, limit, sort, dir, filters, out total); 
		}
		
		#endregion
	}
}
